package com.ws.mapper;

import com.ws.domain.Admins;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AdminsMapper {
    @Select("select * from admins where username = #{username} and password = #{password}")
    Admins login(@Param("username") String username, @Param("password") String password);

    /**
     * 查询所有管理员
     * @return
     */
    @Select("select * from admins")
    List<Admins> findAll();

    /**
     * 添加管理员
     * @param admin
     */
    @Insert("insert into admins values(null, #{username}, #{password})")
    void adminSave(Admins admin);

    /**
     * 重置管理员密码
     * @param admin
     */
    @Update("update admins set password=#{password} where id = #{id}")
    void adminReset(Admins admin);

    /**
     * 删除管理员
     * @param id
     */
    @Delete("delete from admins where id = #{id}")
    void adminDelete(int id);
}
